namespace Crux.Core.Websockets.Metadata;
/// <summary>
/// InvokeMessage
/// </summary>
public class InvokeMessage : Message
{
    /// <summary>
    ///
    /// </summary>
    /// <value></value>
    [JsonProperty("invocationId")]
    public long InvocationId { get; set; }
    /// <summary>
    ///
    /// </summary>
    [JsonProperty("target")]
    public string Target { get; set; } = string.Empty;
    /// <summary>
    ///
    /// </summary>
    [JsonProperty("arguments")]
    public object[] Arguments { get; set; } = System.Array.Empty<object>();
    /// <summary>
    /// 检查方法的合法性
    /// </summary>
    /// <returns></returns>
    public bool CheckMethodLegitimacy()
    {
        if (string.IsNullOrEmpty(this.Target)
        || this.Target.StartsWith(WebsocketConstants.GetterPrefix)
        || this.Target.StartsWith(WebsocketConstants.SetterPrefix)
        || WebsocketConstants.IgnoreMethods.Contains(this.Target))
            return false;

        return true;
    }
}
